﻿using Furion.DynamicApiController;
using HOPU.OnlineSchool.Application.Teachers.Dtos;
using HOPU.OnlineSchool.Application.Teachers.Services;
using HOPU.OnlineSchool.Core;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HOPU.OnlineSchool.Application.Teachers
{
    public class TeacherAppService: IDynamicApiController
    {
        private readonly ITeacherService _teacherService;

        public TeacherAppService(ITeacherService teacherService) 
        {
            _teacherService = teacherService;
        }
        /// <summary>
        /// 获取教师列表
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<PagedList<TeacherListOutput>> List(int page, int limit,TeacherListInput input) 
        {
            return await _teacherService.GetListAsync(page,limit,input);
        }
        /// <summary>
        /// 删除讲师
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<string> Delete(string id) 
        {
            await _teacherService.DeleteAsync(id);
            return "删除成功";
        }
        /// <summary>
        /// 添加讲师
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<string> Add(TeacherAddInput input) 
        {
            await _teacherService.AddAsync(input);
            return "添加成功！";
        }
        /// <summary>
        /// 根据id获取讲师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<TeacherDto> GetById(string id) 
        {
            return await _teacherService.GetTeacherAsync(id);
        }
        /// <summary>
        /// 修改讲师
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<string> Update(string id,[FromBody] TeacherDto dto) 
        {
            await _teacherService.UpdateAsync(id,dto);
            return "修改成功！";
        }
    }
}
